package com.musicalevents.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.sql.JoinType;

import com.musicalevents.dao.ConcertDAO;
import com.musicalevents.entity.Concert;
import com.musicalevents.entity.pk.ConcertPK;

@SuppressWarnings("unchecked")
public class ConcertDAOImpl extends GenericDAOImpl<Concert, ConcertPK> implements ConcertDAO {

	public ConcertDAOImpl(Class<Concert> type) {
		super(type);
	}

	public List<Concert> fetchAllConcertsLinkBandPlaceTown() {
		
		Criteria crit = getSession().createCriteria(Concert.class);
		crit.createAlias("band", "b", JoinType.INNER_JOIN);
		crit.createAlias("place", "p", JoinType.INNER_JOIN);
		crit.createAlias("p.town", "t", JoinType.INNER_JOIN);
		List<Concert> concerts = crit.list();
		return (concerts);
	}
	
}
